package org.redis.cluster.redis;

import java.io.Serializable;

public class RedisCommand implements Serializable {
	
	private String command;

	private int parameterCount;
	private byte parameters[][];
	
	private RedisProtocolType protocolType;
	
	private byte[] source;
	
	public String getCommand() {
		if(command!=null) {
			return command;
		}
		
		command=new String(parameters[0]).toUpperCase();
		return command;
	}
	
	public byte[] getSource() {
		return source;
	}
	
	public byte[][] getParameters() {
		return parameters;
	}
	
	public RedisProtocolType getProtocolType() {
		return protocolType;
	}
	
	public int getParameterCount() {
		return parameterCount;
	}
	
	public void setCommand(String command) {
		this.command = command;
	}

	public void setParameterCount(int parameterCount) {
		this.parameterCount = parameterCount;
	}

	public void setParameters(byte[][] parameters) {
		this.parameters = parameters;
	}

	public void setProtocolType(RedisProtocolType protocolType) {
		this.protocolType = protocolType;
	}

	public void setSource(byte[] source) {
		this.source = source;
	}

	@Override
	public String toString() {
		return String.format("{command:%s,parameterCount:%s,protocolType:%s}", 
				getCommand(),getParameterCount(),getProtocolType());
	}
}